 readonly="readonly"<template>
  <div class="content-box">
    <nav-title title="入公司前工作经历" />
    <div class="line">
      <span class="important"></span>
      <div class="label">开始时间</div>
      <div class="value">
        <group>
          <datetime value-text-align="left" readonly placeholder="请选择" v-model="expwork.startDt"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">结束时间</div>
      <div class="value">
        <group>
          <datetime value-text-align="left" readonly placeholder="请选择" v-model="expwork.endDt"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">工作单位</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="expwork.cCompany" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">职务</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="expwork.cPosition" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">证明人及职务</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="expwork.cDescrlong" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">联系电话</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="expwork.cPhone" readonly="readonly">
      </div>
    </div>
    <div class="submit-btn" @click="save" v-if="showOr">
      保存
    </div>
    <div class="remove-btn" @click="remove" v-if="showOr">
      删除
    </div>
  </div>

</template>

<script>
import { Datetime, Group, PopupPicker } from 'vux'
import { savePWork,delWork } from '../../../api/api'
import { json2Form } from '../../../util/http'

export default {

  name: 'input-information',
  components: {
    Datetime, Group, PopupPicker
  },
  data() {
    return {
      expwork: {
        startDt:'',
        emplid: '10070226',
        cModStauts:'',
        cTransactionNbr:''
      },
      showOr:true
    }
  },
  mounted() {
    if(this.$route.params.cnta){
      this.expwork.cTransactionNbr = this.$route.params.cnta
    }
  },
  created() {
    this.getexps()
  },
  methods: {
    save() {
      if(this.expwork.cModStauts == 'U'){
        this.expwork.cModStauts = 'U'
      }else{
        this.expwork.cModStauts = 'C'
      }
      // if(this.beginDate === ''){
      //   this.$vux.alert.show({
      //     title: '警告',
      //     content: '请选择开始时间'
      //   });
      //   return;
      // }
      // if(this.endDate === ''){
      //   this.$vux.alert.show({
      //     title: '警告',
      //     content: '请选择结束时间'
      //   });
      //   return;
      // }
      // if(this.company === ''){
      //   this.$vux.alert.show({
      //     title: '警告',
      //     content: '请输入工作单位'
      //   });
      //   return;
      // }
      // if(this.position === ''){
      //   this.$vux.alert.show({
      //     title: '警告',
      //     content: '请输入职务'
      //   });
      //   return;
      // }

      console.log(this.expwork)
      savePWork(json2Form(this.expwork)).then(res => {
        const that = this;
        //成功：000000
        if(res && res.retCode === '000000' ){
          //保存成功
          this.$vux.alert.show({
            title: '奥克斯',
            content: '保存成功',
            onHide () {
              that.$router.push({
                    name: 'userBase',
                    params:{
                      cnta: that.expwork.cTransactionNbr
                    }
                  });
            }
          })

        }else{
          this.$vux.alert.show({
            title: '提示',
            content: res.retMsg
          })
        }
      }).catch (res=>{
        this.$vux.alert.show({
          title: '警告',
          content: '网络异常，请稍后重试'
        })
      })

    },
    remove() {
      const _this = this;
      _this.expwork.cModStauts = 'D'
      _this.$vux.confirm.show({
          // 组件除show外的属性
          title: '提示',
          content: '确定删除？',
          onCancel () {
          },
          onConfirm () {
            console.log(_this.expwork)
            savePWork(json2Form(_this.expwork)).then(res=>{
              //成功：000000
              if(res && res.retCode === '000000' ){
                //删除成功
                // _this.$vux.alert.show({
                //   title: '奥克斯',
                //   content: '删除成功',
                //   onHide () {
                    _this.$router.push({
                    name: 'userBase',
                    params:{
                      cnta: _this.expwork.cTransactionNbr
                    }
                  });
                //   }
                // })
              }else{
                _this.$vux.alert.show({
                  title: '提示',
                  content: res.retMsg
                })
              }

            })
            .catch(res=>{
              _this.$vux.alert.show({
                  title: '奥克斯',
                  content: '删除成功',
                  onHide () {
                    _this.$router.push('/');
                  }
                })
            })

          }
        })

    },
    getexps() {
      if(this.$route.params.workexp){
        this.expwork.startDt = this.$route.params.workexp.startDt
        this.expwork.endDt = this.$route.params.workexp.endDt
        this.expwork.cCompany = this.$route.params.workexp.cCompany
        this.expwork.cPosition = this.$route.params.workexp.cPosition
        this.expwork.cDescrlong = this.$route.params.workexp.cDescrlong
        this.expwork.cPhone = this.$route.params.workexp.cPhone
        this.expwork.cSeqno = this.$route.params.workexp.cSeqno
        this.expwork.cModStauts = this.$route.params.cModStauts
        this.expwork.cTransactionNbr = this.$route.params.ctn
        if(!this.$route.params.ctn){
          this.showOr = false
        }
      }

    }
  }
}
</script>
<style type="text/scss" lang="scss" scoped>
@import "./personstyle";
</style>
